(function($) {

	$("#indexMain").attr("href", "/");

	getSession2Redirect();

	// 发送登录请求
	$(".form-submit").on("click", function() {

		var me = this;
		var email = $("#name").val();
		var pwd = $("#password").val();
		var remember = $("#inlineCheckbox2").is(':checked') ? 1 : 0;

		// 验证
		if (email.length <= 0 || !pwd) {
			$("#loginError").show();
			return;
		}

		$.ajax({
			type : "POST",
			url : "/api/account/signin",
			data : {
				"name" : email,
				"password" : pwd,
				"remember" : remember
			},
			dataType: "json"
		}).done(function(data) {
			console.log(data)
			console.log(data.success)
			if (data.success) {
				console.log("true");
				// window.VISITOR = data.result.visitor;
				$("#loginError").hide();
				// headShowInit();
				window.location.href = "/main";
			} else {
				console.log("false");
				Util.input.whiteError($("#loginError"), data);
				$("#loginError").show();
			}
		});
	});

})(jQuery);